<template>
  <view class="goods-item">
    <view class="goods-item-left">
      <image class="good-img" :src="goods.goods_small_logo||defaultPic"></image>
    </view>
    <view class="goods-item-right">
      <p class="goods-name">{{goods.goods_name}}</p>
      <div class="goods-price">￥{{goods.goods_price|toFixed}}</div>
    </view>
  </view>
</template>

<script>
  export default {
    name: "my-goods",
    props: {
      goods: {
        type: Object,
        default: () => {}
      }
    },
    filters: {
      toFixed(num) {
        return num.toFixed(2)
      }
    },

    data() {
      return {
        // 默认的空图片
        defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png'
      };
    }
  }
</script>

<style lang="scss">
  .goods-item {
    display: flex;
    border: 1px solid #f0f0f0;
    padding: 20rpx 10rpx;

    .goods-item-left {
      margin-right: 10rpx;

      .good-img {
        width: 200rpx;
        height: 200rpx;
      }
    }

    .goods-item-right {
      display: flex;
      flex-direction: column;
      justify-content: space-around;

      .goods-name {
        font-size: 26rpx;
      }

      .goods-price {
        color: #c00000;
        font-size: 32rpx;
      }
    }
  }
</style>
